/*global require, __dirname, module*/
var	webpack = require('webpack'),
		path = require('path'),
		extractText = require('extract-text-webpack-plugin'),
		OpenBrowser = require('open-browser-webpack-plugin');

var src = path.join(__dirname, 'src'),
		publish = path.join(__dirname, 'publish');

var option = {
	entry: src,
	output: {
		path: publish,
		filename: 'js/[name].js'
	},
	module: {
		loaders: [{
			test: /\.style$/,
			include: src,
			loaders: ['style']
		}, {
			test: /\.css$/,
			include: src,
			loaders: ['style', 'css']
		}, {
			test: /\.scss$/,
			include: src,
			loader: extractText.extract('style', 'css!sass')
		}, {
			test: /\.jsx?$/,
			include: src,
			loader: 'babel',
			query: {
				presets: ['react', 'es2015']
			}
		}]
  },
	resolve: {
      extensions: ['', '.js', '.jsx']
  },
	// externals: {
  //    'react': 'React',
  //    'react-dom': 'ReactDOM',
  //    'react-router': 'ReactRouter'
  // },
	plugins: [
		new webpack.HotModuleReplacementPlugin(),   // 代码监视
		new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'), //提取公共代码
		// new webpack.optimize.UglifyJsPlugin({
		// 	compress: {
    //     warnings: false
    //   }
		// }),
		new extractText('css/index.css'),
		new OpenBrowser()
	]
};

module.exports = option;
